<?php
/**
 * 轻云网络验证系统
 * =======================================================
 * 版权所有(C) 2019-2039 daenx.cn，并保留所有权利。
 * 作者：Daen大恩
 * 作者QQ: 1330166565
 * 开发群：661059773
 * =======================================================
 */
    include 'farmwork.php';
	header("content-type:text/html;charset=utf-8");
	login();
	
	$sql = "SELECT * FROM daili_con where dl='代理商'"; 
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			  $dls_zhekou = $row['zhekou'];
			  $dls_km1 = $row['km1'];
			  $dls_km2 = $row['km2'];
			  $dls_quan1 = $row['quan1'];
			  $dls_quan2 = $row['quan2'];
	   }
	}
	
	$sql = "SELECT * FROM daili_con where dl='授权商'"; 
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			  $sqs_zhekou = $row['zhekou'];
			  $sqs_km1 = $row['km1'];
			  $sqs_km2 = $row['km2'];
			  $sqs_quan1 = $row['quan1'];
			  $sqs_quan2 = $row['quan2'];
	   }
	}
	
	$sql = "SELECT * FROM daili_con where dl='总销商'"; 
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			  $zxs_zhekou = $row['zhekou'];
			  $zxs_km1 = $row['km1'];
			  $zxs_km2 = $row['km2'];
			  $zxs_quan1 = $row['quan1'];
			  $zxs_quan2 = $row['quan2'];
	   }
	}
	
	$sql = "SELECT * FROM daili_con where dl='超管'"; 
	$result=mysqli_query($con,$sql);
	if($result&&mysqli_num_rows($result)){
	   while ($row=mysqli_fetch_assoc($result)) {
			  $cg_zhekou = $row['zhekou'];
			  $cg_km1 = $row['km1'];
			  $cg_km2 = $row['km2'];
			  $cg_quan1 = $row['quan1'];
			  $cg_quan2 = $row['quan2'];
	   }
	}


	$action = $_GET['action'];
	if($action=='do'){
		$dls_zhekou = $_POST['dls_zhekou'];
		$dls_km1 = $_POST['dls_km1'];
		$dls_km2 = $_POST['dls_km2'];
		$sqs_zhekou = $_POST['sqs_zhekou'];
		$sqs_km1 = $_POST['sqs_km1'];
		$sqs_km2 = $_POST['sqs_km2'];
		$zxs_zhekou = $_POST['zxs_zhekou'];
		$zxs_km1 = $_POST['zxs_km1'];
		$zxs_km2 = $_POST['zxs_km2'];
		$cg_zhekou = $_POST['cg_zhekou'];
		$cg_km1 = $_POST['cg_km1'];
		$cg_km2 = $_POST['cg_km2'];	  
		$sql = "UPDATE `daili_con` SET `zhekou` = '$dls_zhekou', `km1` = '$dls_km1', `km2` = '$dls_km2' where dl='代理商'";
		echo $sql1;
	    mysqli_query($con,$sql);
		$sql = "UPDATE `daili_con` SET `zhekou` = '$sqs_zhekou', `km1` = '$sqs_km1', `km2` = '$sqs_km2' where dl='授权商'";
	    mysqli_query($con,$sql);
		$sql = "UPDATE `daili_con` SET `zhekou` = '$zxs_zhekou', `km1` = '$zxs_km1', `km2` = '$zxs_km2' where dl='总销商'";
	    mysqli_query($con,$sql);
		$sql = "UPDATE `daili_con` SET `zhekou` = '$cg_zhekou', `km1` = '$cg_km1', `km2` = '$cg_km2' where dl='超管'";
	    mysqli_query($con,$sql);
		mysqli_close();
		echo("<script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/js/jquery.min.js\"></script><script language=\"javascript\" type=\"text/javascript\" src=\"/data/assets/layer/layer.js\"></script><script>layer.open({  type: 1  ,title: false   ,closeBtn: false  ,area: '200px;'  ,shade: 0.8  ,id: 'LAY_layuipro'   ,resize: false  ,btn: ['确定']  ,moveType: 1   ,content: '<div style=\"padding: 30px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;\">更新成功！</div>'  ,success: function(layero){ var btn = layero.find('.layui-layer-btn');  btn.find('.layui-layer-btn0').attr({ href: 'setup-dl.php' });  }});</script>");
	}

$li6='class="active"';
$li65='class="active"';
?>
<?php include 'header.php';?>
    <title>代理设置-<?php echo $title?></title>
<?php include 'list.php';?>
    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
<?php include 'overview.php';?>
            <div class="row">
                <div class="col-md-12">
                    <!--work progress start-->
                    <section class="panel">
                        <header class="panel-heading">
                        代理权限设置
                        </header>
                        <div class="panel-body">
						<form class="form-horizontal tasi-form" action="setup-dl.php?action=do" method="post" role="form">
									
									<header class="panel-heading">
									❤ 代理商
									</header>
									<div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">全站折扣</label>
                                        <div class="col-sm-10">
                                             <input type="text" name="dls_zhekou" class="form-control" value='<?php echo $dls_zhekou?>'>
                                        </div>
                                    </div>
									
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">期限卡密生成权限</label>
										<div class="col-sm-10">
											<select name="dls_km1" class="form-control">
											<?php if($dls_km1 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">余额卡密生成权限</label>
										<div class="col-sm-10">
											<select name="dls_km2" class="form-control">
											<?php if($dls_km2 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									
									
									<header class="panel-heading">
									❤ 授权商
									</header>
									<div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">全站折扣</label>
                                        <div class="col-sm-10">
                                             <input type="text" name="sqs_zhekou" class="form-control" value='<?php echo $sqs_zhekou?>'>
                                        </div>
                                    </div>
									
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">期限卡密生成权限</label>
										<div class="col-sm-10">
											<select name="sqs_km1" class="form-control">
											<?php if($sqs_km1 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">余额卡密生成权限</label>
										<div class="col-sm-10">
											<select name="sqs_km2" class="form-control">
											<?php if($sqs_km2 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									
									
									<header class="panel-heading">
									❤ 总销商
									</header>
									<div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">全站折扣</label>
                                        <div class="col-sm-10">
                                             <input type="text" name="zxs_zhekou" class="form-control" value='<?php echo $zxs_zhekou?>'>
                                        </div>
                                    </div>
									
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">期限卡密生成权限</label>
										<div class="col-sm-10">
											<select name="zxs_km1" class="form-control">
											<?php if($zxs_km1 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">余额卡密生成权限</label>
										<div class="col-sm-10">
											<select name="zxs_km2" class="form-control">
											<?php if($zxs_km2 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									
									
									<header class="panel-heading">
									❤ 超管
									</header>
									<div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">全站折扣</label>
                                        <div class="col-sm-10">
                                             <input type="text" name="cg_zhekou" class="form-control" value='<?php echo $cg_zhekou?>'>
                                        </div>
                                    </div>
									
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">期限卡密生成权限</label>
										<div class="col-sm-10">
											<select name="cg_km1" class="form-control">
											<?php if($cg_km1 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
									<div class="form-group">
									<label class="col-sm-2 col-sm-2 control-label">余额卡密生成权限</label>
										<div class="col-sm-10">
											<select name="cg_km2" class="form-control">
											<?php if($cg_km2 == 1)
												{echo '<option value="0">否</option>
												<option value="1" selected>是</option>';}
												else 
												{echo '<option value="0" selected>否</option>
												<option value="1">是</option>';}
											?>
											</select>
										</div>
									</div>
						
                                
			<div id="bottom" class="form-group">
			<label class="col-sm-2 col-sm-2 control-label"></label>
			  <button class="btn btn-info btn-lg" type="submit" value="true" id="submit"/><i class="fa fa-refresh" id="spinner"></i> <span id="btnText">更新设置</span></button>
            </div>
                            </form>
                        </div>
                    </section>
                    <!--work progress end-->
                </div>

        </section>
    </section>
    <!--main content end-->

<?php include 'footer.php';?>